/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package testes;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;

/**
 *
 * @author PRTurbo
 */
public class testeBuffer {

    public static void main(String[] args) throws IOException {
//        InputStream is = new FileInputStream("saida.txt");
//        InputStreamReader isr = new InputStreamReader(is);
//        BufferedReader br = new BufferedReader(isr);
//        String s/* = br.readLine()*/;
//        while ((s = br.readLine()) != null) {
//            System.out.println(s);
//        }
//
//        br.close();


//        InputStream is = System.in;
//        InputStreamReader isr = new InputStreamReader(is);
//        BufferedReader br = new BufferedReader(isr);
//        String s = br.readLine();
//
//        while (s != null) {
//            System.out.println(s);
//            s = br.readLine();
//        }


//        OutputStream os = new FileOutputStream("saida.txt");
//        OutputStreamWriter osw = new OutputStreamWriter(os);
//        BufferedWriter bw = new BufferedWriter(osw);
//
//        bw.write("caelum");
////        bw.newLine();//quebra de linha
//        bw.write("testestestesteste");
//        bw.close();

//
//        FileOutputStream fos = new FileOutputStream("saida.txt",true);
//        
//        fos.write("awdawdawdwad");


        InputStream is = new FileInputStream("programa.txt");
        InputStreamReader isr = new InputStreamReader(is);
        BufferedReader br = new BufferedReader(isr);
//        try (BufferedReader br2 = new BufferedReader(new File("programa.txt"))){
//        
//        }

        String v[] = new String[100];
        String linha;

        int h = 0;

        while ((linha = br.readLine()) != null) {
            v[h] = linha;
            h = h + 1;
        }

        
        OutputStream os = new FileOutputStream("programa.txt");
        OutputStreamWriter osr = new OutputStreamWriter(os);
        BufferedWriter bw = new BufferedWriter(osr);
        int x = 0;
        
        for (int i = 0; i < 100; i++) {
            if (v[i] != null) {
                bw.write(v[i]);
                bw.newLine();
                x = x + 1;
            }
        }

        boolean r = true;
        String linha2[] = new String[10];
        for (int i = 0; i < 10; i++) {
            linha2[i] = "gol" + i;
        }
        for (int j = 0; j < x; j++) {
            for (int i = 0; i < 10; i++) {
                if (v[j].equals(linha2[i])) {
                    r = false;
                }
            }
        }

        if (r == true) {
            for (int i = 0; i < 10; i++) {
                bw.write(linha2[i]);
                bw.newLine();
            }
        }

        bw.close();

        /*
        
         int x = 0;

         String v[] = new String [10];
         int i = 0;
         PrintWriter output = new PrintWriter(new FileWriter("saida.txt", true));

         FileReader input = new FileReader("saida.txt");
         BufferedReader br = new BufferedReader(input);
         String linha = "";

         while ((linha = br.readLine()) != null) {
         v[i] = linha;
         i = i + 1;
         //                if (palavra.equals(linha)) {
         //
         //                    JOptionPane.showMessageDialog(null, "ESSA PALAVRA JÁ EXISTE");
         //
         //                    x = 100;
         //                }

         }
         //
         //            if (x != 100) {
         //
         //                JOptionPane.showMessageDialog(null, "SALVO");
         //
         //                output.append(palavra + "\r\n");
         //
         //                output.close();
         //
         //            }

         output.close();
        
         for (int j = 0; j < 10; j++) {
         System.out.println(v[j]);
            
         }
        
        
         */



//        OutputStream os = new FileOutputStream("saida.txt");
//        OutputStreamWriter osr = new OutputStreamWriter(os);
//        BufferedWriter bw = new BufferedWriter(osr);









//        String s = br.readLine();


    }
}
